//
//  LoginTableViewCell.m
//  一度电力
//
//  Created by 廖幸杰 on 15/12/20.
//  Copyright © 2015年 廖幸杰. All rights reserved.
//

#import "LoginTableViewCell.h"
#import "UIButton+Create.h"
#import "UITextField+Create.h"

@interface LoginTableViewCell (){
    
     UITextField *_userNameTF;
     UITextField *_passwordTF;

}

//@property (nonatomic, strong) UITextField *userNameTF;
//@property (nonatomic, strong) UITextField *passwordTF;

@end
@implementation LoginTableViewCell

-(instancetype)initWithStyle:(UITableViewCellStyle)style reuseIdentifier:(NSString *)reuseIdentifier row:(NSInteger)row{

    self = [super initWithStyle:style reuseIdentifier:reuseIdentifier];
    
    if (self) {
        

        switch (row) {
            case 0:
            {
                CGRect tfFrame = CGRectMake(0, 0, SCREEN_WIDTH, TABLE_VIEW_HEIGHT_FOR_ROW);
                _userNameTF = [UITextField textFieldWithFrame:tfFrame
                                                        placehold:@"账号"
                                                           target:self
                                                              tag:row];
                [self.contentView addSubview:_userNameTF];
                
//                _userNameTF = tf;

            }
                break;
            case 1://账号
                
//                [self cellView:row imageName:@"account" tfPlacehold:@"账号"];
            {
                
                CGRect tfFrame = CGRectMake(0, 0, SCREEN_WIDTH, TABLE_VIEW_HEIGHT_FOR_ROW);
                UITextField *tf = [UITextField textFieldWithFrame:tfFrame
                                                        placehold:@"密码"
                                                           target:self
                                                              tag:row];
                [self.contentView addSubview:tf];
                
                _passwordTF = tf;
            }
                break;
//            case 2://密码
//                [self cellView:row imageName:@"密码" tfPlacehold:@"密码"];
//
//                break;
            case 2://登陆
                [self creatLoginButton:row];
                
                break;
//            case 4://注册和忘记密码
//                [self creatRegisterAndForgetPassworkButton];
//                
//                break;

            default:
                break;
        }
        
    }
    
    return self;
}


#pragma mark - buttonClick
-(void)buttonClick:(UIButton*)button{

    switch (button.tag) {
        case 0://登陆
            
            NSLog(@"_userNameTF == %@",_userNameTF);
            NSLog(@"_passwordTF == %@",_passwordTF);

            break;

        default:
            break;
    }
}
#pragma mark - textFieldDelegate
-(BOOL)textFieldShouldReturn:(UITextField *)textField{

    [textField resignFirstResponder];
    return YES;
}

#pragma mark - 创建登陆按钮
-(void)creatLoginButton:(NSInteger)row{
    
    CGRect frame = CGRectMake(40, 10, SCREEN_WIDTH - 40 *  2, TABLE_VIEW_HEIGHT_FOR_ROW - 10 * 2);
    _loginBtn = [UIButton buttonWithFrame:frame
                                             title:@"登陆"
                                          fontSize:16
                                        titleColor:[UIColor whiteColor]
                                            action:nil
                                            target:self tag:row
                                   backgroundColor:[UIColor blueColor]];
    
    [self.contentView addSubview:_loginBtn];
}



@end
